<!--
 * @Description:: 请补充填写
 * @Version: 请配置版本号
 * @Author: xiaobai
 * @Date: 2021-06-11 09:48:04
 * @LastEditors: smallWhite
 * @LastEditTime: 2024-03-20 11:11:36
 * @FilePath: /huizhou_website/src/views/party/index.vue
-->
<template>
  <div>
    <div class="banner_boxa"  :class="isPhone == 'true'?'banner_imga_phone':''">
      <img :src="bannerUrl"
        class="banner_imga">
      <div
        class="bannenr_texta animation">
        <span>{{ text }}</span>
      </div>
    </div>
    <div class="tabs_boxes"
      v-if="$route.path !='/party_details'">
      <div
        class="tabs_box_overflow">
        <div class="tab"
          @click="gotoPage(item,index)"
          :class="{'active':isActive == item.path}"
          v-for="(item,index) in tabList"
          :key="index">
          {{item.name}}
        </div>
      </div>
    </div>
    <router-view></router-view>
  </div>
</template>

<script>
import axios from 'axios'

export default {
  data() {
    return {
      bannerUrl: '',
      isActive: '/',
      tabList: [],
      text: '党群工作',
      tabsList: {}
    }
  },
  watch: {
    $route: {
      handler: function (val) {
        if (val.path == '/party_details') {
          this.text = '党建详情'
        } else {
          this.text = '党群工作'
        }
        this.isActive = val.path
      }
    }
  },
  mounted() {
    this.tabsList = this.$store.state.navList[4]
    this.tabList = this.$store.state.navList[4].children
    this.getBanner()
    this.isActive = this.$store.state.index
    if (window.localStorage.getItem('isPhone')) this.isPhone = window.localStorage.getItem('isPhone')
    else this.isPhone = 'false'
  },
  methods: {
    gotoPage(item, index) {
      this.$store.commit('setOpenNav', [4, index])
      this.$router.push(item.path)
      this.$store.commit('setPathIndex', item.path)
    },
    getBanner() {
      axios.post('/home/img', { projectId: this.tabsList.id }).then(res => {
        const bannerList = res.data.data.imageList
        bannerList.map(item => {
          this.$set(item, 'imgUrl', res.data.data.imgUrl + '/' + item.url)
        })
        this.bannerUrl = bannerList[0].imgUrl
      })
    }
  }
}
</script>

<style>
</style>